import { Form, View } from '@tarojs/components'
import { Component } from 'react'
import './app.scss'
import { setToken ,setstore , getstore  , userInfo ,} from './pages/model/all'
import ob from './pages/util/funPromise'
// import Taro from '@tarojs/taro' ;
class App extends Component {

  componentDidMount () {}

  componentDidShow () {
    this.wxLogin().then(res=>{
      //需要登录成功之后的操作
      this.getuserInfo()
    })
  }

  componentDidHide () {
  }

  componentDidCatchError () {}

  wxLogin = () => {
    return ob.login()
    .then(res=>{
      return res.code
    })
    // .then(code=>ob.request({url: 'http://182.92.196.159:8090/api/project/front/user/login',
    // data: {
    //   code
    // },method:'POST'})).then(res=>console.log({res}))
    .then(code=>setToken(code))
    .catch(err=>{
      console.log('错误' + err )
    })
  }

  getuserInfo=()=>{
    userInfo().then(res=>{
      console.log(res)
    })
  }

  // this.props.children 是将要会渲染的页面
  render () {
    return this.props.children
  }

}

export default App
